package tag36_29_08.regExWieder;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Exam {

	public static void main(String[] args) throws IOException, Throwable {

		URL url = new URL(
				"http://de.wikipedia.org/wiki/Liste_antiker_Philosophen");

		InputStream is = url.openStream();

		InputStreamReader reader = new InputStreamReader(is, "UTF-8");

		BufferedReader in = new BufferedReader(reader);

		String line;

		while ((line = in.readLine()) != null) {

			while (Pattern.compile("<li><a href=\"/wiki/").matcher(line).find()) {

				System.out.println(line);
				
				String str1 = line.substring(19).substring(0,
						line.substring(19).indexOf('"'));
				System.out.println(str1);

				System.out.println("--> " + line.indexOf("("));
				System.out.println("--> " + line.lastIndexOf(")"));
				String str2 = line.substring(line.indexOf("("),
						line.lastIndexOf(")"));
				System.out.println(str2);
				break;
			}

		}

		in.close();
	}

}
